<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>节点管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="__LAY__/css/layui.css" media="all" />
    <link rel="stylesheet" href="__CSS__/font_eolqem241z66flxr.css" media="all" />
    <link rel="stylesheet" href="__FONT__/css/font-awesome.min.css" media="all" />
    <link rel="stylesheet" href="__CSS__/main.css" media="all" />
    <style>
    </style>
</head>
<body>
<div class="layui-anim layui-anim-upbit right_body">

    <div class="right_content_top">
        <blockquote class="layui-elem-quote">
            <a href="/admin/node/index.html"  class="layui-btn layui-btn-normal" style="background-color: #787f84">
                目录形式展示
            </a>
            <a href="/admin/node/nodelist.html"  class="layui-btn layui-btn-normal">
                列表形式展示
            </a>
        </blockquote>
    </div>

    <fieldset class="layui-elem-field layui-field-title" >
        <legend style="font-size: 14px;">菜单列表<i class="layui-icon"  id="add_rule">&#xe654;</i> </legend>
    </fieldset>
    <!--{empty name='list'}-->
    <p class="help-block text-center well">没 有 记 录 哦！</p>
    <!--{else}-->
    <table id="test" class="layui-table" lay-skin="line">
        <thead>
        <tr>
            <th >序号</th>
            <th >图标</th>
            <th >节点名称</th>
            <th >路径</th>
            <th >是否菜单</th>
            <th>操作</th>
        </tr>
        </thead>
        <col style="width: 60px;"/>
        <col style="width: 70px;"/>
        <tbody>
        <!--{foreach $list as $key=>$vo}-->
        <tr>
            <td >{$i++} </td>
            <td > {$vo.style}</td>
            <td > {$vo.level_mark} {$vo.node_name} </td>
            <td > {$vo.href_name}</td>
            <td > {$vo.is_menu} </td>
            <td >
                <a class="layui-btn layui-btn-sm add_child_rule"  data-id="{$vo.id}"><i class="layui-icon">&#xe654;</i>  添加子菜单</a>
                <a class="layui-btn layui-btn-sm layui-btn-mini edit_rule" data-id="{$vo.id}"><i class="layui-icon">&#xe642;</i> 修改</a>
                <a class="layui-btn layui-btn-sm layui-btn-mini del_rule" data-id="{$vo.id}"><i class="layui-icon">&#xe640;</i> 删除</a>
            </td>
        </tr>

        <!--{/foreach}-->
        </tbody>
    </table>
    <!--{/empty}-->

</div>

</body>
<script type="text/javascript" src="__JS__/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="__LAY__/layui.js"></script>
<script type="text/javascript" src="__JS__/index.js"></script>
<script src="https://cdn.bootcss.com/limonte-sweetalert2/7.21.1/sweetalert2.all.js"></script>
<script>

    //添加父菜单
    $('#add_rule').on('click',function () {
        layer.open({
            type: 2,
            content: ["{:url('node/addnode',['pid'=>'0'])}"],
            area: ['50%', '80%']
        });
    });

    //添加子菜单
    $("body").on("click",".add_child_rule",function(){
        var url =   window.location.pathname;
        tmpHPage = url.split( "/" );
        tmpHPage.pop();
        url =  tmpHPage.join("/");
        var _this = $(this);
        var id =  _this.attr("data-id");
        layer.open({
            type: 2,
            content:  url+"/addnode?pid="+id,
            area: ['50%', '80%']
        });
    });

    //修改菜单
    $("body").on("click",".edit_rule",function(){
        var url =   window.location.pathname;
        tmpHPage = url.split( "/" );
        tmpHPage.pop();
        url =  tmpHPage.join("/");
        var _this = $(this);
        var id =  _this.attr("data-id");
        layer.open({
            type: 2,
            content:  url+"/editnode?id="+id,
            area: ['50%', '80%']
        });
    });

    //删除菜单
    $("body").on("click",".del_rule",function(){
        var _this = $(this);
        var id =  _this.attr("data-id");
        swal({
            title: "确定删除吗？",
            text: "删除后将无法恢复",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "确定删除！",
            cancelButtonText: "取消删除！",
            closeOnConfirm: false,
            closeOnCancel: false
        })
            .then(function(isConfirm){
                if(isConfirm.value) {
                    $.post("{:url('node/nodedel')}",{'id':id},function (res) {
                        if(1 == res.code){
                            swal({
                                text: "删除成功",
                                type: "success",
                                confirmButtonText: "确定删除！",
                                closeOnConfirm: false,
                                closeOnCancel: false,
                                showCancelButton:false,
                                showConfirmButton:true,
                            }).then(function(isConfirm){
                                window.location.reload();
                            })
                        }else if(111 == res.code){
                            window.location.reload();
                        }else{
                            swal("取消！", res.msg,
                                "error");
                        }
                    })
                } else {
                    swal("取消！", "感谢您没有把我删除奥",
                        "error");
                }
            });
    });
</script>
</html>